import req from '@/utils/request';
export const createLoan = (loanInfo) => req.post('/loan/create', loanInfo);
export const loanLost = (params) =>
  req.get('/loan/list', {
    params,
  });
export const rejectLoan = (id) =>
  req.post('/approve/first/reject', {
    appId: id,
    loanId: id,
  });

export const passLoan = (id) =>
  req.post('/approve/first/pass', {
    appId: id,
    loanId: id,
  });

export const rejectLoanEnd = (id) =>
  req.post('/approve/end/reject', {
    appId: id,
    loanId: id,
  });

export const passLoanEnd = (id) =>
  req.post('/approve/end/pass', {
    appId: id,
    loanId: id,
  });
export const getContractUrl = (id) =>
  req
    .get('/contract/download', {
      params: { id },
    })
    .then((res) => {
      return res.data.data.url;
    });
export const downloadByUrl = (url) => {
  // /api/contract/download/contract-94.docx
  const newUrl = url.replace('/api', '');
  return req.get(newUrl, {
    responseType: 'blob', // new Blob([arrayBuffer])
  });
};
